package anthology.daily_question._25_02;
//https://leetcode.cn/problems/remove-duplicates-from-sorted-array-ii/?envType=daily-question&envId=2025-02-09
public class _0080删除有序数组中的重复项2 {
    class Solution {
        public int removeDuplicates(int[] nums) {
            int n = nums.length;
            if (n <= 2) {
                return n;
            }
            int slow = 2, fast = 2;
            while (fast < n) {
                if (nums[slow - 2] != nums[fast]) {
                    nums[slow] = nums[fast];
                    ++slow;
                }
                ++fast;
            }
            return slow;
        }
    }
}
